import request from '@/api/request'
import axios from 'axios'
import qs from 'qs'

const http = {
    /**
     * method:请求
     * @params url 请求地址
     * @params params 请求参数
     * */
    //列表+详情
    get(url,params){
        const config = {
            method:'get',
            url:url
        }
        if(params) config.params = params
        return request(config)
    },
    //新增
    post(url,params){
        const config = {
            method:'post',
            url:url,
        }
        if(params) config.data = qs.stringify(params)
        return request(config)
    },
    //上传图片
    postImages(url,params){
        const config = {
            method:'post',
            url:url,
            headers: {
                'content-type': 'multipart/form-data',
            },
        }
        if(params) config.data = params
        return request(config)
         
     },
    post_t(url,params){
        let token = weixin.getToken()
        return axios({
            headers:{
               'token': token,
                'content-type':'application/json;charset=utf-8',
                'Authorization':'' + token
            },
            url:url,
            method:'post',
            data:params
        })
    },
     //修改
     put(url,params){
        const config = {
            method:'put',
            url:url
        }
        if(params) config.data = qs.stringify(params)
        return request(config)
    },

}

export default http